
const { exec } = require("child_process");

let changeToCustomerInputItem = [
  {
    name: `[False] - Not Install This Package.`,
    value: false,
    short: `false`
  },
  {
    name: `[False] - Customer Input.`,
    value: 'to_cus',
    short: 'to_cus'
  },
]

// TODO 插件不能使用 Promise 类型返回。待想办法

let electronListObj = {
  pkgName: 'electron',
  defaultVersionCode: 'latest',
  defaultVersion: `latest`,
  list: [
    {
      name: `latest : latest`,
      value: `latest`,
      short: `latest`
    },
    ...changeToCustomerInputItem
  ]
}
let electronBuilderListObj = {
  pkgName: 'electron-builder',
  defaultVersionCode: '21.2.0',
  defaultVersion: `^21.2.0`,
  list: [
    {
      name: `Default latst.(@21.2.0)`,
      value: `^21.2.0`,
      short: `^21.2.0`
    },
    ...changeToCustomerInputItem
  ]
}
let electronDebugListObj = {
  pkgName: 'electron-debug',
  defaultVersionCode: '3.0.1',
  defaultVersion: `^3.0.1`,
  list: [
    {
      name: `Default latst.(@3.0.1)`,
      value: `^3.0.1`,
      short: `^3.0.1`
    },
    ...changeToCustomerInputItem
  ]
}

module.exports = pkg => {
  return [
    {
      name: "appId",
      type: "input",
      message: `Input 'appId'：`,
      default: "com.test.app"
    },
    {
      name: "productName",
      type: "input",
      message: `Input 'productName'：`,
      default: "default app"
    },
    // electron@version
    {
      name: "eleVersion",
      type: "list",
      message: "Choose Electron Version：",
      default: electronListObj.defaultVersion,
      choices: electronListObj.list
    },
    {
      name: "eleVersion",
      type: "input",
      message: "Input Electron Version：",
      default: electronListObj.defaultVersion,
      when(asked) {
        return asked.eleVersion === 'to_cus';
      }
    },
    // electron-builder@version
    {
      name: "eleBuilderVersion",
      type: "list",
      message: "Choose electron-builder Version：",
      default: electronBuilderListObj.defaultVersion,
      choices: electronBuilderListObj.list
    },
    {
      name: 'eleBuilderVersion',
      type: "input",
      message: "Input electron-builder Version：",
      default: electronBuilderListObj.defaultVersion,
      when(asked) {
        return asked.eleBuilderVersion === 'to_cus';
      }
    },
    // electron-debug@version
    {
      name: "eleDebugVersion",
      type: "list",
      message: "Choose electron-debug Version：",
      default: electronDebugListObj.defaultVersion,
      choices: electronDebugListObj.list
    },
    {
      name: 'eleDebugVersion',
      type: "input",
      message: "Input electron-debug Version：",
      default: electronDebugListObj.defaultVersion,
      when(asked) {
        return asked.eleDebugVersion === 'to_cus';
      }
    },
    // devtools install type
    {
      name: 'devtoolsInstallType',
      type: "rawlist",
      message: "Choose devtoolsInstallType：",
      default: 'none',
      choices: [
        {
          name: 'Dowload from Google server.',
          value: 'chrome',
          short: 'chrome'
        },
        {
          name: 'Customer File Path.',
          value: 'file',
          short: 'file'
        },
        {
          name: 'None.',
          value: 'none',
          short: 'none'
        }
      ]
    }
  ]
}
